package com.evaluation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evaluation.entity.DeptEvaluatingRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 部门测评关系Mapper接口
 */
@Mapper
public interface DeptEvaluatingRelationMapper extends BaseMapper<DeptEvaluatingRelation> {

    /**
     * 批量插入部门测评关系数据
     */
    void batchInsert(@Param("list") List<DeptEvaluatingRelation> list);

    /**
     * 获取教师待测评部门列表（包含指标名称）
     */
    @Select("SELECT d.*, i.zbmc FROM t_dept_evaluating_relation d " +
            "LEFT JOIN t_indicators i ON d.cpzbbh = i.zbbh " +
            "WHERE d.cpjs = #{jsxm} AND d.cpbs = '0' " +
            "ORDER BY d.bcpbm")
    List<Map<String, Object>> getPendingByTeacherWithIndicatorName(@Param("jsxm") String jsxm);

    /**
     * 获取教师已测评部门列表（包含指标名称）
     */
    @Select("SELECT d.*, i.zbmc FROM t_dept_evaluating_relation d " +
            "LEFT JOIN t_indicators i ON d.cpzbbh = i.zbbh " +
            "WHERE d.cpjs = #{jsxm} AND d.cpbs = '1' " +
            "ORDER BY d.cpsj DESC")
    List<Map<String, Object>> getEvaluatedByTeacherWithIndicatorName(@Param("jsxm") String jsxm);
}
